package com.chengliang.zuoye.controller;

import com.chengliang.zuoye.bean.Classes;
import com.chengliang.zuoye.response.JsonResult;
import com.chengliang.zuoye.service.ClassService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author chengliang
 * @Date 2019-06-24 15:32
 * @Description //TODO
 *  班级控制器
 */
@Controller
@RequestMapping("/class")
public class ClassController {

    private Logger logger= LoggerFactory.getLogger(getClass());

    @Autowired
    private ClassService classService;

    /**
     * @return
     * 班级列表首页
     */
    @GetMapping("/index")
    public String index(){
        return "class/index";
    }

    @GetMapping("/data/json")
    @ResponseBody
    public Object dataJson(){
        List<Classes> classesList = classService.classList();
        logger.debug("班级列表数据"+classesList);
        return JsonResult.ok(classesList);
    }


}
